package ${sourceBasePackage}.controller;

import com.idp.common.base.BaseController;
import com.idp.common.model.JsonModel;
import com.idp.common.model.PageModel;
import ${sourceBasePackage}.api.${entityName}Api;
import ${sourceBasePackage}.dto.${entityName}Dto;
import ${sourceBasePackage}.dto.${entityName}SearchDto;
import ${sourceBasePackage}.service.${entityName}Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * ${description}Controller
 * @author ${author}
 */
@RestController
public class ${entityName}Controller extends BaseController implements ${entityName}Api {

	@Autowired
	private ${entityName}Service ${entityName?uncap_first}Service;

	@Override
	public JsonModel findByPage(${entityName}SearchDto ${entityName?uncap_first}SearchDto) {

		JsonModel json = new JsonModel();
		json.setData(${entityName?uncap_first}Service.findByPage(${entityName?uncap_first}SearchDto));

		return json;
	}

	@Override
	public JsonModel getById(${entityName}Dto ${entityName?uncap_first}Dto) {

		JsonModel json = new JsonModel();
		json.setData(${entityName?uncap_first}Service.getById(${entityName?uncap_first}Dto.get${pkPropertyName?cap_first}()));

		return json;
	}

	@Override
	public JsonModel add(${entityName}Dto ${entityName?uncap_first}Dto) {

		JsonModel json = new JsonModel();
		${entityName?uncap_first}Service.add(${entityName?uncap_first}Dto);
		json.setMessage("新增成功");

		return json;
	}

	@Override
	public JsonModel update(${entityName}Dto ${entityName?uncap_first}Dto) {

		JsonModel json = new JsonModel();
		${entityName?uncap_first}Service.update(${entityName?uncap_first}Dto);
		json.setMessage("修改成功");

		return json;
	}

	@Override
	public JsonModel delete(${entityName}Dto ${entityName?uncap_first}Dto) {

		JsonModel json = new JsonModel();
		${entityName?uncap_first}Service.delete(${entityName?uncap_first}Dto.get${pkPropertyName?cap_first}());
		json.setMessage("删除成功");

		return json;
	}

}
